package com.yousu.dashijixm.validation;

import com.yousu.dashijixm.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @Author: YouSu
 * @Version: 1.0
 * @CreateTime: 2023-11-23  15:13
 * 自定义注解的校验规则
 */
//实现ConstraintValidator<给那个注解提供校验规则，校验的类型>
public class StateValidation implements ConstraintValidator<State,String> {
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (s == null){
            return false;
        }
        if (s.equals("已发布") || s.equals("草稿")){
            return true;
        }
        return false;
    }
}
